<template>
	<view>
		<uni-popup ref="uppwd">
			<view class="bgfff ra30 width880 posire pt50 pb50">
				<image @click="$refs.uppwd.close()" mode="widthFix" class="image posiab right30 top20 width50"
					src="/static/img/bi.png"></image>
				<view class="size36 color333 bold flex-a-i ml50 mb60">
					<view class="wh6-30 mt8 bg2C7BFF mr15"></view>个人信息
				</view>
				<view class="flex-a-i">
					<view class="width250 text-right"><text class="colorFC474C">*</text>原密码：</view>
					<view class="width480">
						<el-input class=" pl20 ra5" show-password type="password" v-model="pwass" placeholder="请输入密码" />
					</view>

				</view>
				<view class="flex-a-i mt40 mb40">
					<view class="width250 text-right"><text class="colorFC474C">*</text>新密码：</view>
					<view class="width480">
						<el-input class=" pl20 ra5" show-password type="password" v-model="newpwass"
							placeholder="请输入密码" />
					</view>
				</view>
				<view class="flex-a-i">
					<view class="width250 text-right"><text class="colorFC474C">*</text>确认密码：</view>
					<view class="width480">
						<el-input class=" pl20 ra5" show-password type="password" v-model="dnewpwass"
							placeholder="请再次输入密码" />
					</view>
				</view>

				<view class="flex-ju-c">
					<view class="flex-a-i mt80">
						<view @click="$refs.uppwd.close()" class="wh152-64 borderd0d6dc flex-ju-c ra5">取消</view>
						<view @click="sctrue" class="wh152-64 border165DFF colorfff bg165dff flex-ju-c ml60 ra5">确定
						</view>
					</view>
				</view>
			</view>

		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: "poup",
		props: [],
		data() {
			return {
				pwass: "",
				newpwass: "",
				dnewpwass: "",
			};
		},
		created() {

		},
		methods: {
			close() {
				this.$refs.uppwd.close()
			},
			open() {
				this.pwass = ""
				this.newpwass = ""
				this.dnewpwass = ""
				this.$refs.uppwd.open()
			},
			sctrue() {
				if (!this.pwass) {
					uni.showToast({
						title: '输入原密码',
						icon: 'none',
					})
					return
				}
				if (!this.newpwass) {
					uni.showToast({
						title: '输入密码',
						icon: 'none',
					})
					return
				}
				if (!this.dnewpwass) {
					uni.showToast({
						title: '确认密码',
						icon: 'none',
					})

					return
				}
				if (this.newpwass !== this.dnewpwass) {
					uni.showToast({
						title: '密码不一致',
						icon: 'none',
					})
					return
				}
				if (!this.isValidPassword(this.dnewpwass)) {
					uni.showToast({
						title: '4~6个字，必须包含数字，如有特殊字符仅支持.$!%*?&',
						icon: 'none',
					})
					return
				}

				this.$emit('sctrue', this.pwass, this.newpwass, this.dnewpwass)
			},
			isValidPassword(password) { //改密码定义正则表达式
				const passwordPattern = /^(?=.*[0-9])[$.$!%*?&0-9]{4,6}$/;
				return passwordPattern.test(password);
			}
		}
	}
</script>

<style>

</style>